﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VideoClubGorbea.Common.Interfaces;
using VideoClubGorbea.Model;
using VideoClubGorbea.ServicesClient.Interfaces;

namespace VideoClubGorbea.ServicesClient
{
    public class CustomMovieServicesCient : IMovieServicesClient
    {
        public IMovieServices MovieServices { get; set; }

        public CustomMovieServicesCient(IMovieServices movieServices)
        {
            MovieServices = movieServices;
        }

        public List<Movie> GetLatestMovies(int? pageSize)
        {
            var result = MovieServices.GetLatestMovies(pageSize);
            return result;
        }

        public Task<List<Movie>> GetLatestMoviesAsync(int? pageSize)
        {
            var task = new Task<List<Movie>>(()=>{ 
            
                var taskResult = MovieServices.GetLatestMovies(pageSize);
                return taskResult;
            });
            return task;
        }

        public Movie GetMovieById(int? id)
        {
            var result = MovieServices.GetMovieById(id);
            return result;
        }

        public Task<Movie> GetMovieByIdAsync(int? id)
        {
            var task = new Task<Movie>(() =>
            {
                var taskResult = MovieServices.GetMovieById(id);
                return taskResult;
            });
            return task;
        }

        public List<Movie> SearchMovies(string title)
        {
            var result = MovieServices.SearchMovies(title);
            return result;
        }

        public Task<List<Movie>> SearchMoviesAsync(string title)
        {
            var task = new Task<List<Movie>>(() =>
            {
                var taskResult = MovieServices.SearchMovies(title);
                return taskResult;
            });
            return task;
        }
    }
}
